<template>
  <section>
    <div class="filter-container">
      <common-input type="number" @keyup.enter.native="handleFilter" class="w100" placeholder="商品编号"
        v-model="listQuery.productNo" v-if="!cardType && !isPackage" />
      <common-input @keyup.enter.native="handleFilter" class="w100 ml10" placeholder="商品名称"
        v-model="listQuery.keyword" />
      <el-select class="ml10" @change="getCateList(false)" size="mini" v-model="listQuery.parentCateId"
        placeholder="一级分类" v-if="!cardType && !isPackage">
        <el-option v-for="item in parentCateList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
      <el-select size="mini" class="ml10" v-model="listQuery.cateId" placeholder="二级分类" v-if="!cardType && !isPackage">
        <el-option v-for="item in cateList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
      <el-select class="ml10" clearable size="mini" v-model="listQuery.limitUser" placeholder="新人购"
        v-if="!cardType && !isPackage">
        <el-option v-for="item in limitUserList" :key="item.id" :label="item.name" :value="item.id">
        </el-option>
      </el-select>
      <el-button size="mini" class="ml10" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
      <el-button class="ml10" size="mini" type="primary" @click="exportExcel">导出</el-button>
      <el-button size="mini" class="ml10" type="primary" icon="el-icon-upload" @click="handleImport">导入</el-button>
      <el-button size="mini" class="ml10" type="primary" @click="handleSync"
        v-if="!cardType && !isPackage">同步</el-button>
      <!-- <el-button v-if="cardType>0||isPackage" size="mini" class="ml10" type="primary" icon="el-icon-plus" @click="handleCreate">发布</el-button> -->
      <el-button size="mini" class="ml10" type="primary" icon="el-icon-plus" @click="handleCreate">发布</el-button>
    </div>
    <el-tabs size="mini" :before-leave='leaveTab' v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="全部商品" name="0"></el-tab-pane>
      <el-tab-pane label="出售中" name="1"></el-tab-pane>
      <!-- <el-tab-pane label="已售罄" name="2"></el-tab-pane> -->
      <el-tab-pane label="待售中" name="3"></el-tab-pane>
      <el-tab-pane label="已删除" name="4"></el-tab-pane>
    </el-tabs>
    <el-alert v-if="!isSku && ids && ids.length > 0" show-icon>
      <template slot="title">
        <span>已选择 {{ ids.length }} 项</span> <el-button @click="clear()" type="text">清空</el-button>
        <template v-if="!isSelect">
          <el-button v-if="activeName == '1' || activeName == '0'" @click="down()" type="text">批量下架</el-button>
          <el-button v-else-if="activeName == '3' || activeName == '0'" @click="up()" type="text">批量上架</el-button>
        </template>
        <template v-else>
          <el-button @click="select()" type="text">选择</el-button>
        </template>
      </template>
    </el-alert>
    <el-table ref="dataTable" :height="tableHeight" :data="list" @sort-change="tblSort" @selection-change="selectChange"
      style="width: 100%">
      <el-table-column fixed type="selection" width="55">
      </el-table-column>
      <el-table-column align="right" width="80" label="排序" sortable="custom" prop="order_num">
        <template slot-scope="scope">
          <span>{{ scope.row.orderNum }}</span>
          <i @click="editOrder(scope.row)" class="el-icon-edit ml10" style="cursor:pointer;color:#F4222D;"></i>
        </template>
      </el-table-column>
      <el-table-column align="left" label="商品编号" v-if="!cardType && !isPackage">
        <template slot-scope="scope">
          <span>{{ scope.row.ycProductId }}</span>
        </template>
      </el-table-column>
      <el-table-column align="left" label="" width="120">
        <template slot-scope="scope">
          <span><img :src="scope.row.listImgUrl" style="width:80px;cursor:pointer;"
              @click="viewPic(scope.row)" /></span>
        </template>
      </el-table-column>
      <el-table-column align="left" label="商品" width="250">
        <template slot-scope="scope">
          <div>
            {{ scope.row.title }}
            <p style="color:red;margin-top:3px;" v-if="!scope.row.market && scope.row.ycReason">{{ scope.row.ycReason }}
            </p>
          </div>
        </template>
      </el-table-column>
      <el-table-column align="left" label="分类1" v-if="!cardType && !isPackage">
        <template slot-scope="scope">
          <span v-if="scope.row.parentCateId > 0">{{ scope.row.parentCateName }}<span v-if="scope.row.cateId > 0">-{{
            scope.row.cateName }}</span><span v-if="scope.row.thirdCateId > 0">-{{ scope.row.thirdCateName
              }}</span></span>
        </template>
      </el-table-column>
      <el-table-column align="left" label="分类2" v-if="!cardType && !isPackage">
        <template slot-scope="scope">
          <span v-if="scope.row.parentCateId2 > 0">{{ scope.row.parentCateName2 }}<span v-if="scope.row.cateId2 > 0">-{{
            scope.row.cateName2 }}</span><span v-if="scope.row.thirdCateId2 > 0">-{{ scope.row.thirdCateName2
              }}</span></span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="是否可自提" prop="sale_count">
        <template slot-scope="scope">
          <span v-if="scope.row.isVerification == 1">否</span>
          <span v-if="scope.row.isVerification == 2">是</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="销量" sortable="custom" prop="sale_count">
        <template slot-scope="scope">
          <span>{{ scope.row.saleCount }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="虚拟销量" sortable="custom" prop="virtual_sale_count">
        <template slot-scope="scope">
          <span>{{ scope.row.virtualSaleCount }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="供货成本" sortable="custom" prop="min_supply_price"
        v-if="!cardType">
        <template slot-scope="scope">
          <span>￥{{ scope.row.minSupplyPrice }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="运费成本" sortable="custom" prop="freight_price" v-if="!cardType">
        <template slot-scope="scope">
          <span>￥{{ scope.row.freightPrice }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="售价" sortable="custom" prop="min_sale_price">
        <template slot-scope="scope">
          <span>￥{{ scope.row.minSalePrice }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="抵扣" sortable="custom" prop="redpacket"
        v-if="!cardType && !isPackage">
        <template slot-scope="scope">
          <span>{{ scope.row.redpacket }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="利润" sortable="custom" prop="profit" v-if="!cardType">
        <template slot-scope="scope">
          <span>￥{{ scope.row.profit }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="创建时间" width="150" sortable="custom" prop="created_at">
        <template slot-scope="scope">
          <span>{{ scope.row.createdAt }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="库存" sortable="custom" prop="inventory">
        <template slot-scope="scope">
          <span>{{ scope.row.inventory }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" align="right" label="最低数量" sortable="custom" prop="min_num" v-if="cardType > 0">
        <template slot-scope="scope">
          <span>{{ scope.row.minNum }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" fixed="right" v-if="!isSelect">
        <template slot-scope="scope">
          <span>
            <el-dropdown class="ml10">
              <el-button type="text">
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="handleDetail(scope.row)">查看</el-dropdown-item>
                <el-dropdown-item v-if="scope.row.canEdit == 1"
                  @click.native="handleUpdate(scope.row)">编辑</el-dropdown-item>
                <el-dropdown-item v-if="scope.row.canUp == 1" @click.native="handleUp(scope.row)">上架</el-dropdown-item>
                <el-dropdown-item v-if="scope.row.canDown == 1"
                  @click.native="handleDown(scope.row)">下架</el-dropdown-item>
                <el-dropdown-item v-if="scope.row.canDelete == 1"
                  @click.native="handleDelete(scope.row)">删除</el-dropdown-item>
                <el-dropdown-item v-if="scope.row.canRecovery == 1"
                  @click.native="handleRecovery(scope.row)">恢复</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="操作" fixed="right" v-if="isSelect && isSku">
        <template slot-scope="scope">
          <span>
            <el-button type="text" @click="handleSku(scope.row)">选择sku</el-button>
          </span>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page.sync="listQuery.pageNum" :page-sizes="[20, 30, 50]" :page-size="listQuery.pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="total"> </el-pagination>
    </div>

    <el-dialog title="编辑排序" :visible.sync="dialogOrderVisible" :close-on-click-modal="false" width="300px">
      <el-form :model="orderForm" ref="orderForm" label-width="80px">
        <el-form-item label="排序" prop="orderNum">
          <el-input size="mini" type="number" placeholder="" maxlength="3" v-model="orderForm.orderNum" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="dialogOrderVisible = false">取消</el-button>
        <el-button :loading="orderLoading" size="mini" type="primary" @click="okOrder">确定</el-button>
      </div>
    </el-dialog>


    <el-dialog title="选择SKU" :visible.sync="isShowSKUInformtion" :close-on-click-modal="false" width="800px"
      append-to-body>
      <template v-if="productDetail">
        <div class="shop">
          <div class="shop-top">商品：{{ productDetail.title }}</div>
          <el-table :data="productDetail.skuInfo" style="width:100%" border max-height="680">
            <el-table-column label='规格名' prop='name'></el-table-column>
            <el-table-column label='规格值' prop='value'></el-table-column>
            <el-table-column label='供货价格'>
              <template slot-scope="scope">
                <p>¥ {{ scope.row.supplyPrice }}</p>
              </template>
            </el-table-column>
            <el-table-column label='售价'>
              <template slot-scope="scope">
                <p>¥ {{ scope.row.salePrice }}</p>
              </template>
            </el-table-column>
            <el-table-column label='商品库存' prop='inventory'></el-table-column>
            <el-table-column align="center" label="操作" fixed="right">
              <template slot-scope="scope">
                <span>
                  <el-button type="text" @click="handleFinalSku(scope.row)">选择</el-button>
                </span>
              </template>
            </el-table-column>
            <!-- <el-table-column label='* 库存预警值'>
              <template slot-scope="scope">
                <div class="stock">{{scope.row.warning_stock}}</div>
              </template>
            </el-table-column> -->
          </el-table>
        </div>

      </template>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="mini" @click="isShowSKUInformtion = false">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog title="批量导入" :visible.sync="dialogImportVisible" :close-on-click-modal="false" :append-to-body="true"
      width="80%">
      <product-import @okCreate="okImport" />
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" @click="dialogImportVisible = false">关闭</el-button>
      </div>
    </el-dialog>

  </section>
</template>

<script>
import {
  product_list,
  product_delete,
  product_update_order,
  product_detail,
  product_update_stock,
  product_up,
  product_down,
  product_category,
  product_sync,
  productExport,
  product_recovery
} from '../../api/product';
import Viewer from 'viewerjs';
import 'viewerjs/dist/viewer.css';
export default {
  components: {
    'product-import': () => import('../../components/Product/import'),
  },
  props: {
    formData: Object
  },
  data() {
    return {
      dialogImportVisible: false,
      isShowSKUInformtion: false,
      productDetail: {},
      isSelect: false,
      isSku: false,
      viewerId: null,
      orderLoading: false,
      tableHeight: 200,
      cateList: [],
      parentCateList: [],
      limitUserList: [
        {
          id: 1,
          name: "是"
        },
        {
          id: 2,
          name: "否"
        }
      ],
      list: null,
      listLoading: true,
      listQuery: {
        pageNum: this.$route.query.pageNum || 1,
        pageSize: this.$route.query.pageSize || 20,
        agency: undefined,
        keyword: this.$route.query.keyword,
        auditStatus: '3',
        orderCol: "",
        orderAsc: "",
        cateId: this.$route.query.cateId,
        parentCateId: this.$route.query.parentCateId,
        status: '0',
        getSaleCount: 1,
        limitUser: this.$route.query.limitUser,
        productNo: this.$route.query.productNo,
        isPackage: 0,
        isVerification: 0
      },
      total: null,
      activeName: '0',
      currentId: 0,
      checkLoading: false,
      dialogOrderVisible: false,
      orderForm: {
        id: 0,
        orderNum: 0,
      },
      productForm: {
        id: 0,
        hasSku: 0,
        skuInfo: [],
        inventory: 0,
      },
      dialogStockVisible: false,
      stockLoading: false,
      ids: [],
      cardType: 0,
      selectList: [],
      isPackage: 0,
    }
  },
  watch: {
    formData: {
      immediate: true,
      handler(val) {
        this.isSelect = val.is_select;
        this.isSku = val.is_sku;
        this.cardType = val.card_type || 0;
        this.isPackage = val.is_package || 0;
        this.listQuery.isVerification = val.isVerification
        // console.log(val)
      }
    }
  },
  mounted() {
    const that = this

    window.onresize = () => {

      return (() => {

        that._getTableHeight()

      })()
    }
  },
  created() {
    this._getTableHeight();
    this.getParentCateList();
    this.getList();
  },
  methods: {
    okImport() {
      this.dialogImportVisible = false;
      this.getList();
    },
    handleFinalSku(item) {
      this.isShowSKUInformtion = false;
      let result = {
        title: this.productDetail.title,
        attribute: item.attribute,
        productId: this.productDetail.id,
        skuId: item.id,
        price: item.salePrice,
        skuInventory: item.inventory,
        supplyPrice: item.supplyPrice,
        freightPrice: this.productDetail.freightPrice,
      };
      this.$emit('okSkuSelect', result);
    },
    handleSku(item) {
      product_detail(item.id).then((res) => {
        this.productDetail = res.data;
        this.isShowSKUInformtion = true
      }).catch((err) => {

      })

    },
    _getTableHeight() {
      this.tableHeight = window.innerHeight - 250
    },
    getList() {
      this.listLoading = true;
      if (this.cardType == 3) {
        this.listQuery.isCard = 1;
        this.listQuery.cardType = 0;
      } else {
        this.listQuery.isCard = this.cardType > 0 ? 1 : 0;
        this.listQuery.cardType = this.cardType;
      }
      this.listQuery.isPackage = this.isPackage ? 1 : 0;
      product_list(this.listQuery).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.listLoading = false;
      })
    },
    viewPic(row) {
      if (row.imgUrls) {
        let all_pic = row.imgUrls.split(",");
        $("#pic_viewer").html("");
        if (all_pic && all_pic.length > 0) {
          all_pic.forEach((item, idx) => {
            var str = '<li style="width:100%;">';
            str += '<img rel-src="' + item + '" src="' + item + '">';
            str += '</li>';
            $("#pic_viewer").append(str);
          })
        }
        this.viewerId && this.viewerId.destroy()
        this.viewerId = new Viewer(document.getElementById('pic_viewer'));
        $('#pic_viewer').find("img").eq(0).trigger("click")
      }
    },
    getParentCateList() {
      product_category(0).then((res) => {
        this.parentCateList = res.data;
        this.cateList = []
      }).catch((err) => {
        this.parentCateList = []
        this.cateList = []
      });
    },
    getCateList() {
      this.listQuery.cateId = undefined;
      product_category(this.listQuery.parentCateId).then((res) => {
        this.cateList = res.data;
      }).catch((err) => {
        this.cateList = []
      });
    },
    handleFilter() {
      this.listQuery.pageNum = 1;
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum = val;
      this.getList();
    },
    handleClick(tab, event) {
      this.listQuery.status = this.activeName;
      this.handleFilter();
      // console.log(this.activeName)
    },
    leaveTab(activeName, oldActiveName) {
      // console.log(activeName)
      // return false;
    },
    handleUpdate(row) {
      let url = "/goods_edit?id=" + row.id + "&from=" + encodeURIComponent(this.$router.currentRoute.name)
        + "&pageSize=" + encodeURIComponent(this.listQuery.pageSize)
        + "&pageNum=" + encodeURIComponent(this.listQuery.pageNum);

      if (this.listQuery.keyword) {
        url += "&keyword=" + encodeURIComponent(this.listQuery.keyword);
      }
      if (this.listQuery.productNo) {
        url += "&productNo=" + encodeURIComponent(this.listQuery.productNo);
      }
      if (this.listQuery.parentCateId) {
        url += "&parentCateId=" + this.listQuery.parentCateId;
      }
      if (this.listQuery.cateId) {
        url += "&cateId=" + this.listQuery.cateId;
      }
      if (this.listQuery.limitUser) {
        url += "&limitUser=" + this.listQuery.limitUser;
      }
      this.$router.push(url)
    },
    handleDelete(row) {
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          product_delete(row.id)
            .then(() => {
              this.$message.success("商品删除成功");
              this.getList();
            });
        }).catch(() => { });
    },
    handleRecovery(row) {
      this.$confirm('确定恢复商品?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          product_recovery(row.id)
            .then(() => {
              this.$message.success("商品恢复成功");
              this.getList();
            });
        }).catch(() => { });
    },
    handleDetail(row) {
      let { href } = this.$router.resolve({ path: '/goods_detail?id=' + row.id });
      window.open(href, '_blank');
    },
    dialogClose() {
      this.$refs.form.resetFields();
    },
    tblSort(d) {
      this.listQuery.orderCol = d.prop;
      this.listQuery.orderAsc = d.order;

      this.handleFilter();
    },
    editOrder(row) {
      this.orderForm.id = row.id;
      this.orderForm.orderNum = row.orderNum;

      // console.log(this.orderForm)
      this.dialogOrderVisible = true;
    },
    okOrder() {
      this.orderLoading = true;
      product_update_order(this.orderForm).then((res) => {
        this.orderLoading = false;
        this.dialogOrderVisible = false;
        this.$message.success("排序已更新");

        this.getList();
      }).catch((err) => {
        this.orderLoading = false;
      })
    },
    editStock(row) {
      product_detail(row.id).then((res) => {
        this.productForm.id = res.data.id;
        this.productForm.hasSku = res.data.hasSku;
        this.productForm.inventory = res.data.inventory;
        this.productForm.skuInfo = res.data.skuInfo;

        this.dialogStockVisible = true;

        console.log(this.productForm)
      }).catch((err) => {

      })
    },
    makeMinStock() {
      let p = 0;
      if (this.productForm.skuInfo && this.productForm.skuInfo.length > 0) {
        this.productForm.skuInfo.forEach((item) => {
          if (item.inventory) {
            p += Number(item.inventory) || 0
          }
        })
      }
      this.productForm.inventory = p;
    },
    okStock() {
      this.stockLoading = true;
      product_update_stock(this.productForm).then((res) => {
        this.stockLoading = false;
        this.dialogStockVisible = false;
        this.$message.success("库存已更新");

        this.getList();
      }).catch((err) => {
        this.stockLoading = false;
      })
    },
    selectChange(selection) {
      this.ids = [];
      this.selectList = [];
      if (selection && selection.length > 0) {
        selection.forEach((item) => {
          this.ids.push(item.id)
          this.selectList.push(item);
        })
      }
      // console.log(this.ids)
    },
    clear() {
      this.$refs.dataTable.clearSelection();
    },
    up(ids) {
      if (!ids || ids.length < 1) {
        ids = this.ids;
      }
      this.$confirm('确定上架?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          product_up({
            ids: ids
          })
            .then(() => {
              this.$message.success("商品上架成功");
              this.getList();
            });
        }).catch(() => { });
    },
    down(ids) {
      if (!ids || ids.length < 1) {
        ids = this.ids;
      }
      this.$confirm('确定下架?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          product_down({
            ids: ids
          })
            .then(() => {
              this.$message.success("商品下架成功");
              this.getList();
            });
        }).catch(() => { });
    },
    handleUp(row) {
      this.up([row.id]);
    },
    handleDown(row) {
      this.down([row.id]);
    },
    select() {
      this.$emit('okSelect', this.ids);
      this.$emit('okSelectList', this.selectList);
    },
    handleCreate() {
      let url = "";
      if (this.isPackage) {
        url += "goods_package_create?";
      } else {
        url += "goods_card_create?card_type=" + this.cardType;
      }
      url += "&from=" + encodeURIComponent(this.$router.currentRoute.name)
        + "&pageSize=" + encodeURIComponent(this.listQuery.pageSize)
        + "&pageNum=" + encodeURIComponent(this.listQuery.pageNum);
      if (this.listQuery.keyword) {
        url += "&keyword=" + encodeURIComponent(this.listQuery.keyword);
      }
      if (this.listQuery.productNo) {
        url += "&productNo=" + encodeURIComponent(this.listQuery.productNo);
      }
      if (this.listQuery.parentCateId) {
        url += "&parentCateId=" + this.listQuery.parentCateId;
      }
      if (this.listQuery.cateId) {
        url += "&cateId=" + this.listQuery.cateId;
      }
      this.$router.push(url)
    },
    handleSync() {
      this.$confirm('确定同步云仓商品上下架状态?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          product_sync()
            .then(() => {
              this.$message.success("云仓商品上下架状态已同步");
              this.getList();
            });
        }).catch(() => { });
    },
    createCellPos(n) {
      var ordA = 'A'.charCodeAt(0);

      var ordZ = 'Z'.charCodeAt(0);

      var len = ordZ - ordA + 1;

      var s = "";



      while (n >= 0) {

        s = String.fromCharCode(n % len + ordA) + s;

        n = Math.floor(n / len) - 1;

      }

      return s;

    },
    handleImport() {
      this.dialogImportVisible = true;
    },
    exportExcel() {
      if (this.cardType == 3) {
        this.listQuery.isCard = 1;
        this.listQuery.cardType = 0;
      } else {
        this.listQuery.isCard = this.cardType > 0 ? 1 : 0;
        this.listQuery.cardType = this.cardType;
      }
      this.listQuery.isPackage = this.isPackage ? 1 : 0;
      productExport(this.listQuery).then((res) => {
        if (res.data.items && res.data.items.length > 0) {
          let items = res.data.items;

          let export_config = res.data.exportConfig;
          items.unshift(export_config.header)

          var column = null;
          eval("column = " + export_config.columnJs);
          console.log(column)
          let export_data = LAY_EXCEL.filterExportData(items, column);
          let sheet_data = new Object();
          eval("sheet_data." + res.data.sheet + "=export_data;");
          let cellPos = this.createCellPos(parseInt(export_config.columnCount) - 1);

          LAY_EXCEL.setExportCellStyle(export_data, "A1:" + cellPos + "1", {
            s: {
              fill: { fgColor: { rgb: "FFFF00" } },
              alignment: {
                horizontal: 'center',
                vertical: 'center'
              },
              font: {
                sz: 12,
                bold: true
              }
            }
          });

          LAY_EXCEL.exportExcel(sheet_data, res.data.fileName, 'xlsx', {
            extend: {
              '!merges': export_config.mergeCells,
              '!cols': export_config.width,
              '!rows': LAY_EXCEL.makeRowConfig({
                1: 40
              })
            }
          });
        } else {
          this.$message.error("导出数据为空");
        }
      }).catch((err) => {
        console.log(err)
      })
    }
  }
};
</script>
<style lang="scss" scoped></style>
